<template>
	<view class="content mine-page">
		<uni-nav-bar title="个人中心"></uni-nav-bar>
		<view class="hd-wrap">
			<image src="../../static/images/user.png" class="user-icon"></image>
			<view>
				<view class="name">{{ userName }}</view>
				<view class="no" @click="toMineData">查看个人资料</view>
			</view>
		</view>
		<button class="logout-btn" hover-class="btn-active" @click="logout">退出登录</button>
	</view>
</template>

<script>
	import { mapMutations } from 'vuex'
	export default {
		data () {
			return {

			}
		},
		computed: {
			userName() {
				return this.$store.state.userName.nickname
			}
		},
		onReady() {

		},
		methods: {
			// 退出登录
			logout(){
				uni.showModal({
					title: '是否退出登录？',
					success: (res) => {
						if (res.confirm) {
							this.LOGOUT()
							uni.reLaunch({
								url: '../login/login'
							})
						}
					}
				})
			},
			toMineData(){
				uni.navigateTo({
					url: '../../mainPages/mineData/mineData'
				})
			},
			...mapMutations(['LOGOUT'])
		}
	}
</script>

<style lang="scss" scoped>
	.mine-page {
		width: 100%;
		min-height: calc(100vh - 173rpx);
		background: #F9F9F9;
		.hd-wrap {
			display: flex;
			align-items: center;
			height: 200rpx;
			padding: 0 40rpx;
			// margin-top: 85px;
			background: #FFFFFF;
			.user-icon {
				width: 100rpx;
				height: 100rpx;
				margin-right: 20rpx;
			}
			.no {
				margin-top: 10rpx;
				color: $uni-text-color-grey;
				font-size: $uni-font-size-base;
			}
		}
		.logout-btn {
			color: #FFFFFF;
			background-color: #1a73e8;
			margin: 30rpx 5%;
			&.btn-active {
				background-color: #1c67df;
			}
		}
	}
</style>